package com.irdstudio.bsp.console.api.rest;

import java.util.List;
import java.util.Map;

import com.irdstudio.bsp.console.service.vo.BpmBaseInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.irdstudio.bsp.console.service.facade.BpmBaseInfoService;
import com.irdstudio.sdk.beans.core.vo.ResponseData;
import com.irdstudio.sdk.ssm.web.AbstractController;

@RestController
@RequestMapping("/api")
public class BpmBaseInfoController extends AbstractController  {
	
	@Autowired
	@Qualifier("bpmBaseInfoServiceImpl")
	private BpmBaseInfoService bpmBaseInfoService;

	
	/**
	 * 列表数据查询
	 * @param page
	 * @param size
	 * @return
	 */
	@RequestMapping(value="/bpm/base/infos", method=RequestMethod.POST)
	public @ResponseBody ResponseData<List<BpmBaseInfoVO>> queryBpmBaseInfoAll(
			BpmBaseInfoVO vo) {		
		List<BpmBaseInfoVO> outputVo = bpmBaseInfoService.queryAllOwner(vo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键查询详情
	 * @return
	 */
	@RequestMapping(value="/bpm/base/info/{bpmId}", method=RequestMethod.GET)
	public @ResponseBody ResponseData<BpmBaseInfoVO> queryByPk(@PathVariable("bpmId") String bpmId) {		
		BpmBaseInfoVO inVo = new BpmBaseInfoVO();
				inVo.setBpmId(bpmId);
		BpmBaseInfoVO outputVo = bpmBaseInfoService.queryByPk(inVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键删除信息
	 * @param bpmBaseInfo
	 * @return
	 */
	@RequestMapping(value="/bpm/base/info", method=RequestMethod.DELETE)
	public @ResponseBody ResponseData<Integer> deleteByPk(@RequestBody BpmBaseInfoVO inBpmBaseInfoVo) {		
		int outputVo = bpmBaseInfoService.deleteByPk(inBpmBaseInfoVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键更新信息
	 * @param inBpmBaseInfoVo
	 * @return
	 */
	@RequestMapping(value="/bpm/base/info", method=RequestMethod.PUT)
	public @ResponseBody ResponseData<Integer> updateByPk(@RequestBody BpmBaseInfoVO inBpmBaseInfoVo) {		
		int outputVo = bpmBaseInfoService.updateByPk(inBpmBaseInfoVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 新增数据
	 * @param inBpmBaseInfoVo
	 * @return
	 */
	@RequestMapping(value="/bpm/base/info", method=RequestMethod.POST)
	public @ResponseBody ResponseData<Integer> insertBpmBaseInfo(@RequestBody BpmBaseInfoVO inBpmBaseInfoVo) {
		int outputVo = bpmBaseInfoService.insertBpmBaseInfo(inBpmBaseInfoVo);
		return getResponseData(outputVo);
		
	}

	@RequestMapping(value="/bpm/base/infos/flowdata/{bpmId}", method=RequestMethod.GET)
	public @ResponseBody ResponseData<Map<String, Object>> queryBpmBaseInfoFlowData(
			@PathVariable("bpmId") String bpmId) {

		Map<String, Object> res = bpmBaseInfoService.queryBpmBaseInfoFlowData(bpmId);
		return getResponseData(res);
	}


	@RequestMapping(value="/bpm/base/infos/flowdata", method=RequestMethod.POST)
	public @ResponseBody ResponseData<Boolean> queryBpmBaseInfoFlowData(
			@RequestBody Map<String, Object> flowData) {

		Boolean res = bpmBaseInfoService.saveBpmBaseInfoFlowData(flowData);
		return getResponseData(res);
	}
}
